import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import * as fileApi from '@/api/fileApi'

export const usePreviewAudioStore = defineStore('previewAudioStore', () => {

  const show = ref(false)
  const absolutePath = ref('')
  const title = ref('')
  const fileName = ref(null)
  function audio() {
    return fileName.value ? zipAudio(fileName.value) : fileApi.preview(absolutePath.value)
  }
  function zipAudio(fileName) {
    return fileApi.openZipFile(absolutePath.value,fileName)
  }
  function preview() {
    return audio()
  }
  return {show,audio,absolutePath,title,fileName,preview}

})
